import config from "./config";
import wall from "./canvas/wall";
import steel from "./canvas/steel";
import water from "./canvas/water";
export default {
  isCanvasTouch(x: number, y: number, width: number = config.model.width, height: number = config.model.height): boolean {
    if (
      x < 0 ||
      x + width > config.canvas.width ||
      y < 0 ||
      y + height > config.canvas.hieght
    ) {
      return true;
    };
    return false;
  },
  isModelTouch(
    x: number,
    y: number,
    width: number = config.model.width,
    height: number = config.model.height,
    models: IModel[] = [...steel.modelist, ...wall.modelist, ...water.modelist]
  ): IModel | undefined{
    let touch = models.find(model => {
      let status = !(x + width < model.posX || x > model.width + model.posX || y + height < model.posY || y > model.posY + model.height);
      return status;
    });
    return touch;
  }
}
